<?php
class Mf_user_actorModel {
	static $_table = 'mf_user_actor';
	static $_pk = 'aid';
	static $_db = null;

	static function db(){
		if(self::$_db)
			return self::$_db;
		
		self::$_db = DbLib::getDbStatic('',self::$_table,self::$_pk);
		return self::$_db;
	}
	
	public static function __callStatic($func, $arguments){
		return call_user_func_array(array(self::db(),$func), $arguments);
	}


	static function getOne($uid, $name){
		$sql = "select * from ".self::$_table." where uid = '$uid' and name = '$name'";
		return self::db()->getRow($sql);
	}

	static function create($data){
		return self::db()->add( $data );
	}
	
	static function getOneByAid($aid){
		$sql = "select * from ".self::$_table." where aid = '$aid'";
		return self::db()->getRow($sql);
	}

	static function getAll($uid){
		$sql = "select * from ".self::$_table." where uid = '$uid'";
		return self::db()->getAll($sql);
	}
	
	static function update($data,$table = '',$where){
		if( empty($table) ){
			$table = self::$_table;
		}
		return self::db()->update( $data, $table ,$where );
	}

	static function count($table='',$filed = '*', $where  = ''){
		if( empty($table) ){
			$table = self::$_table;
		}
		return self::db()->countTableTotal( $table,$filed, $where );
	}
}